using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

public class EnemyFactory:ICharacterFactory
{
    public ICharacter CreateCharacter<T>(WeaponType weaponType, Vector3 spawnPosition, int lv = 1) where T : ICharacter, new()
    {
        ICharacter character = new T();

        //创建角色游戏对象
        // 一.1.加载资源 2.实例化 todo
        // 二.添加武器 todo
        // 三.设置属性 todo
        
        // string iconSprite = "";
        // string prefabName = "";
        // string name = "";
        // int maxHp = 0;
        // float moveSpeed = 0;

        //根据类型设置属性
        // System.Type type = typeof(T);
        // if (type == typeof(EnemyElf))
        // {
        //     iconSprite = "ElfIcon";
        //     prefabName = "Enemy1";
        //     name = "小精灵";
        //     maxHp = 100;
        //     moveSpeed = 5;
        // } else
        // {
        //     Debug.LogError("SoldierFactory: CreateCharacter: Type not found");
        //     return null;
        // }

        // 一.1.加载资源 2.实例化
        // 完成加载和实例化 (FactoryManager.assetFactory.LoadSoldier)
        // GameObject characterGO = FactoryManager.assetFactory.LoadEnemy(prefabName);
        // 设置属性
        // characterGO.transform.position = spawnPosition;
        // character.gameObject = characterGO;
        // ICharacterAttr attr = new EnemyAttr(new EnemyAttrStrategy(), lv, new CharacterBaseAttr(name, maxHp, moveSpeed, iconSprite, prefabName));
        // character.attr = attr;
        // 添加武器
        // IWeapon weapon = FactoryManager.weaponFactory.CreateWeapon(weaponType);
        // character.weapon = weapon;
        // return character;
        ICharacterBuilder builder = new EnemyBuilder(character, typeof(T), weaponType, spawnPosition, lv);

        return CharacterBuilderDirector.Construct(builder);
    }
}